import numpy as np

# a=np.array([[1,2,3],[1,2,3],[1,2,3]])
# b=np.array([1,2,3])
# # 奇异矩阵
# print(a.dot(b))
#
# print(a)
# print(a.T) # 转置
# print(np.linalg.pinv(a))  #求逆矩阵


from datas import datas
X=[]
Y=[]
cityMark={"吕梁":1,"太原":2}
for item in datas:
    single=[]
    single.append(cityMark[item["city"]])
    single.append(item["area"])
    single.append(item["rooms"])
    single.append(item["school"])
    single.append(item["style"])
    X.append(single)
    Y.append(item["price"])

X=np.array(X)
Y=np.array(Y)


theta=np.linalg.pinv(X.T.dot(X)).dot(X.T).dot(Y)
print(theta.dot(np.array([1,100,1,2,1])))
# print(theta)



